package com.utils;
import com.common.enums.PX4CustomMainMode;
import com.common.enums.PX4CustomSubModeAuto;

/**
 * @className: CustomModeHelper
 * @description: TODO 类描述
 * @author: Li Chuanwei
 * @date: 2024/07/04 0:38
 * @Company: Copyright [日期] by [作者或个人]
 **/

public class CustomModeHelper {

    public static String getCustomModeState(long customMode) {
        long mainMode = (customMode >> 16) & 0xFF;
        long subMode = (customMode >> 24) & 0xFF;

        if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_MANUAL.getValue()) {
            return "手动模式";
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_ALTCTL.getValue()) {
            return "定高模式";
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_POSCTL.getValue()) {
            return "定点模式";
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_AUTO.getValue()) {
            if (subMode == PX4CustomSubModeAuto.PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF.getValue()) {
                return "起飞";
            } else if (subMode == PX4CustomSubModeAuto.PX4_CUSTOM_SUB_MODE_AUTO_LOITER.getValue()) {
                return "悬停";
            } else if (subMode == PX4CustomSubModeAuto.PX4_CUSTOM_SUB_MODE_AUTO_MISSION.getValue()) {
                return "任务模式";
            } else if (subMode == PX4CustomSubModeAuto.PX4_CUSTOM_SUB_MODE_AUTO_RTL.getValue()) {
                return "返航";
            } else if (subMode == PX4CustomSubModeAuto.PX4_CUSTOM_SUB_MODE_AUTO_LAND.getValue()) {
                return "降落";
            } else {
                return "未知";
            }
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_ACRO.getValue()) {
            return "特技模式";
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_OFFBOARD.getValue()) {
            return "板外模式";
        } else if (mainMode == PX4CustomMainMode.PX4_CUSTOM_MAIN_MODE_STABILIZED.getValue()) {
            return "自稳模式";
        } else {
            return "未知";
        }
    }
}